#pragma once

#include <stdint.h>
#include <unistd.h>

namespace tnet
{
    class SnowflakeIdGenerator 
    {
    public:
        static uint32_t datacenterID(uint16_t dataid,uint16_t workid);
        static uint64_t generator_id(uint32_t datacenter_workid);
        static uint64_t generator_id();
    private:
        
        static pid_t gettid( void );
        static uint64_t get_curr_ms();
        static uint64_t wait_next_ms(uint64_t lastStamp);
        static int atomic_incr(int id);

        SnowflakeIdGenerator() = default;
        ~SnowflakeIdGenerator() = default;
        SnowflakeIdGenerator(const SnowflakeIdGenerator&) = delete;
        SnowflakeIdGenerator& operator=(const SnowflakeIdGenerator&) = delete;
    };
}